package com.naiterui.ehp.ps.push.controller;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.utils.lang.ConfigUtil;
import com.naiterui.ehp.ps.push.vo.MqttRouteVo;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("push/serverInfo")
@Api(tags = {SwaggerTag.PUSH + SwaggerTag.OTHER})
public class MqttServerInfoController {

    @RequestMapping("getInfo")
    public @ResponseBody
    MqttRouteVo getInfo(Long userId, String userType) {

        MqttRouteVo vo = new MqttRouteVo();
        vo.setHost(ConfigUtil.getString("mqttUrl"));
        vo.setPort(ConfigUtil.getInt("mqttPort"));
        vo.setConnectionTimeout(300);
        vo.setKeepAliveInterval(300);
        vo.setCleanSession(true);
        vo.setWillTopicName("");
        vo.setPublicTopicName("bm/d/a/pub");
        vo.setPrivateTopicName("bm/d/a/" + userId);
        vo.setSslProperties(null);

        return vo;
    }

    @RequestMapping("getImInfo")
    public @ResponseBody
    MqttRouteVo getInImfo() {

        MqttRouteVo vo = new MqttRouteVo();
        vo.setHost(ConfigUtil.getString("imChatUrl"));
        vo.setPort(ConfigUtil.getInt("imChatPort"));
        vo.setConnectionTimeout(30);
        vo.setKeepAliveInterval(1);
        vo.setCleanSession(true);
        vo.setWillTopicName("clientWillDead");
        vo.setSslProperties(null);

        return vo;
    }

}
